#lang racket


(provide vector-rotate
         vector-rotate-left
         vector-rotate-right)


; info: positive 'n' rotates left; negative 'n' rotates right
(define (vector-rotate v n)
  (let ((n (modulo n (vector-length v))))
    (let-values (((v1 v2) (vector-split-at v n)))
      (vector-append v2 v1))))

(define (vector-rotate-left v (n 1))
  (vector-rotate v (abs n)))

(define (vector-rotate-right v (n -1))
  (vector-rotate v (- (abs n))))